﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace GSync
{
    public abstract class InternalEntry
    {
        public InternalEntry()
        {
            CanSynchronize = true;
        }
        public string ID { get; set; }

        public bool IsNew
        {
            get
            {
                return !CachedHash.HasValue;
            }
        }

        public bool HasChanged
        {
            get
            {
                return CachedHash.HasValue && (CachedHash.Value != GetHashCode());
            }
        }

        protected int? CachedHash
        {
            get
            {
                CacheRecord rec = GSyncFactory.Instance.GetHashCodesCache()[ID];
                return (rec != null ? new int?(rec.HashCode) : null);
            }
        }
        public string Notes { get; set; }

        public bool Processed { get; set; }


        protected int GetHash(object o)
        {
            if (o == null)
                return 0;
            else
                return o.GetHashCode();
        }

        public bool CanSynchronize { get; set; }

        public object InternalObject { get; set; }



    }
}
